package ink.yql.dao;

import ink.yql.model.Accountnumber;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AccountnumberDao {
    @Select("select * from accountnumber where uid = #{uid} and andefault = 1")
    Accountnumber getByUidDefault(@Param("uid") Integer uid);

    @Select("select * from accountnumber where uid = #{uid}")
    List<Accountnumber> getByUid(@Param("uid") Integer uid);

    @Select("select * from accountnumber where anid = #{anid}")
    Accountnumber getByAnid(@Param("anid") Integer anid);

    @Insert("insert into accountnumber (uid,anaccountNumber,andefault) values(#{uid},#{anaccountNumber},#{andefault})")
    Integer addOne(Accountnumber accountnumber);

    @Update("update accountnumber set anaccountNumber=#{anaccountNumber} ,andefault=#{andefault} where anid=#{anid}")
    Integer update(Accountnumber accountnumber);

    @Delete("delete from accountnumber where anid = #{anid} ")
    Integer delete(@Param("anid") Integer anid);
    @Update("update accountnumber set andefault = 0 where uid =#{uid} ")
    Integer updateDefaultByUid(@Param("uid") Integer uid);
}
